﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="TestMultiplyFactor.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Mathematics.LinearAlgebra.Sequential.Tests.CMFlattenDenseMatrixTest.DoubleExtensions
{
    #region Usings

    using System;

    using ExulLibrary.Mathematics.LinearAlgebra.Sequential.DoubleExtensions;

    using NUnit.Framework;

    #endregion

    /// <summary>
    ///     Test suite for <see cref="CMFlattenDenseMatrixExtensions.Multiply(CMFlattenDenseMatrix{double},double)"/>.
    /// </summary>
    [TestFixture]
    [Category("ExulLibrary.Mathematics.LinearAlgebra.Sequential.DoubleExtensions.CMFlattenDenseMatrixExtensions")]
    public sealed class TestMultiplyFactor
    {
        /// <summary>
        ///     Tests the method.
        /// </summary>
        [Test]
        public void TestMethod()
        {
            // Arrange
            var data = new double[]
                       {
                           1, 2,
                           3, 4,
                           5, 6
                       };
            var matrix = new CMFlattenDenseMatrix<double>(2, 3, data);
            var expectedData = new double[]
                               {
                                   10, 20,
                                   30, 40,
                                   50, 60
                               };

            // Act
            matrix.Multiply(10);

            // Assert
            Assert.That(matrix.Values, Is.EquivalentTo(expectedData));
        }

#if SAFE

        /// <summary>
        ///     Tests the method when matrix parameter is <see langword="null"/>.
        /// </summary>
        [Test]
        public void WhenMatrixIsNull()
        {
            // Arrange
            const double Factor = 10;

            // Act and Assert
            Assert.That(
                () => CMFlattenDenseMatrixExtensions.Multiply(null, Factor),
                Throws.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("matrix"));
        }

#endif
    }
}